<?php
/*
Primary Author: Alex Arey
Secondary: Derek Shue
Documentation: Cheng Yi
Updated: 12/10/2011
Module Description: The Partner Create Internship Form is used by Community Partners to request Interns.
*/
class Application_Form_PartnerCreateIntern extends Zend_Form
{
	
	private $contacts;
	
	public function __construct(array $params = array()) {
		$this->contacts = $params['contacts'];
		parent::__construct();
	}
	
    public function init()
    {
		$tagmodel = new Application_Model_DbTable_Tagnames();
		$tags = $tagmodel -> getAllTagnames();

		$tagoptions = array();

		if($tags){
		foreach($tags as $tag){
			$tagoptions[$tag['TAGNAME']] = $tag['TAGNAME'];
		}
		}
	
	
	
        $this->setMethod('post');

		$nameLenValid = new Zend_Validate_StringLength(array('max' => 30));
		$shortTextLenValid = new Zend_Validate_StringLength(array('max'=>8));
		$medTextLenValid = new Zend_Validate_StringLength(array('max' => 60));
		$longTextLenValid = new Zend_Validate_StringLength(array('max' => 120));
		$veryLongTextLenValid = new Zend_Validate_StringLength(array('max' => 1000));
		$datevalid = new Zend_Validate_Regex(array(
			'pattern' => '/^((1[012])|(0\d))\/((3[01])|([012]\d))\/\d\d\d\d$/'));
		$datevalid->setMessages(array(
				'regexNotMatch'=>'Invalid Date Format. Valid is MM/DD/YYYY'));
		$phonevalid = new Zend_Validate_Regex(array(
			'pattern' => '/^\d\d\\\d\d-\d\d\d\d$/'));
		$phonevalid->setMessages(array(
				'regexNotMatch'=>'Invalid Phone Number Format. Valid is (###)###-####'));
		
	$this->addElement('text','title',array(
	    'label' => 'Position Title:',
        'required' => true,
	    'filters' => array('StringTrim'),
	    'validators' => array($longTextLenValid)
	    )
	);

	$this->addElement('text','numRequesting',array(
	    'label' => 'Number of Positions Requesting:',
            'required' => true,
	    'validators' => array('Digits',$shortTextLenValid)
	    )
	);

	$this->addElement('multiCheckbox','requirements',array(
	    'label' => 'Special Requirements:',
	    'multiOptions'=>array(
		'Car needed for internship position' => 'Car needed for internship position',
		'Bike/Walk from UNC campus'   => 'Bike/Walk from UNC campus',
		'Car needed to/from position' => 'Car needed to/from position',
		'Heavy Lifting' => 'Heavy Lifting',
		'Interview' => 'Interview',
		'Spanish Proficiency' => 'Spanish Proficiency',
		'TB Test'  => 'TB Test'
	        )
	    )
	);

	$this->addElement('text','startDate',array(
	    'label' => 'Approximate start date for internship:(MM/DD/YYYY)',
            'required' => true,
			'validators' => array($datevalid)
	    )
	);

	$this->addElement('text','endDate',array(
	    'label' => 'Approximate end date for internship:',
            'required' => true,
			'validators' => array($datevalid)
	    )
	);

	$this->addElement('textarea','responsibilities',array(
	    'label' => 'Intern\'s Main Responsibilities:',
	    'filters' => array('StringTrim'),
        'required' => true,
        'validators' => array($veryLongTextLenValid)
	    )
	);

	$this->addElement('textarea','eduGoals',array(
	    'label' => 'Educational Opportunities:',
	    'filters' => array('StringTrim'),
	    'validators' => array($veryLongTextLenValid),
	    'required' => true
	    )
	);

	$this->addElement('textarea','majors',array(
	    'label' => 'Required/Preferred Majors or Academic Programs:',
	    'filters' => array('StringTrim'),
	    'validators' => array($veryLongTextLenValid),
	    'required' => true
	    )
	);

	$this->addElement('textarea','importance',array(
	    'label' => 'Importance of Major:',
	    'filters' => array('StringTrim'),
	    'validators' => array($veryLongTextLenValid),
	    'required' => true
	    )
	);

	$this->addElement('select','supervisor',array(
		'label' => 'Supervisor',
		'required=>true',
		'filters' => array('StringTrim'),
		'multioptions' => $this->contacts
		)
	);
	
// 	$this->addElement('text','supervisor',array(
// 	    'label' => 'Supervisor',
//             'required' => true,
// 	    'filters' => array('StringTrim'),
// 	    'validators' => array($medTextLenValid)
// 	    )
// 	);
	
	$this->addElement('radio','isContact',array(
	    'label' => 'Is this person different from the agency contact?',
	    'required' => true,
	    'multiOptions' => array('y'=>'Yes','n'=>'No'),
	    'separator'=>''
            )
	);

	$this->addElement('textarea','structure',array(
	    'label' => 'Mentor/Supervision Structure:',
	    'filters' => array('StringTrim'),
	    'validators' => array($veryLongTextLenValid),
	    'required' => true
	    )
	);

	$this->addElement('textarea','support',array(
	    'label' => 'What other support from APPLEs courses or internships are you receiving at this time?',
	    'filters' => array('StringTrim'),
	    'validators' => array($veryLongTextLenValid),
	    'required' => true
	    )
	);

	$this->addElement('text','staff',array(
	    'label' => 'Number of staff that support your work	:',
	    'filters' => array('StringTrim'),
	    'validators' => array($shortTextLenValid),
	    'required' => true
	    )
	);

	$this->addElement('radio','otherInterns',array(
	    'label' => 'Do you have other student interns?',
	    'required' => true,
	    'multiOptions' => array('y'=>'Yes','n'=>'No'),
	    'separator'=>''
            )
	);

	$this->addElement('textarea','needDesc',array(
	    'label' => 'Describe in terms of hours worked, number of students, and work accomplished:',
	    'filters' => array('StringTrim'),
	    'validators' => array($veryLongTextLenValid),
	    'required' => true
	    )
	);

	$this->addElement('textarea','benefits',array(
	    'label' => 'Please tell us how an APPLES intern would benefit your organization:',
	    'filters' => array('StringTrim'),
	    'validators' => array($veryLongTextLenValid),
	    'required' => true
	    )
	);
	

	$this->addElement('multiCheckbox', 'TAGNAMES', array('label'=>'Associated Tags:','multiOptions'=> $tagoptions, 'required'=>false));

	
	$this->addElement('submit','submit',array(
	    'label' => 'Submit Request')
	);

    }
}

